﻿using System.Collections.Generic;
using System.Net;
using System.Text;

namespace Lyh.XianGuo.Reader.Common
{
    public class HttpParameter
    {
        private string _url = string.Empty;
        /// <summary>
        /// 地址
        /// </summary>
        public string Url
        {
            get { return _url; }
            set { _url = value; }
        }

        private HttpMethod _method = HttpMethod.GET;
        /// <summary>
        /// 方式
        /// </summary>
        public HttpMethod Method
        {
            get { return _method; }
            set { _method = value; }
        }

        private string _host = string.Empty;
        /// <summary>
        /// 主机
        /// </summary>
        public string Host
        {
            get { return _host; }
            set { _host = value; }
        }

        private string _origin = string.Empty;
        /// <summary>
        /// 源
        /// </summary>
        public string Origin
        {
            get { return _origin; }
            set { _origin = value; }
        }

        private string _referer = string.Empty;
        /// <summary>
        /// 引用
        /// </summary>
        public string Referer
        {
            get { return _referer; }
            set { _referer = value; }
        }

        private Dictionary<string, string> _data = new Dictionary<string, string>();
        /// <summary>
        /// 提交的数据
        /// </summary>
        public Dictionary<string, string> Data
        {
            get { return _data; }
            set { _data = value; }
        }

        private string _userAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1707.0 Safari/537.36";
        /// <summary>
        /// 用户代理
        /// </summary>
        public string UserAgent
        {
            get { return _userAgent; }
            set { _userAgent = value; }
        }

        private int _timeout = 20000;
        /// <summary>
        /// 超时时间
        /// </summary>
        public int Timeout
        {
            get { return _timeout; }
            set { _timeout = value; }
        }

        private bool _allowAutoRedirect = true;
        /// <summary>
        /// 允许自动重定向
        /// </summary>
        public bool AllowAutoRedirect
        {
            get { return _allowAutoRedirect; }
            set { _allowAutoRedirect = value; }
        }

        private Encoding _encoding = Encoding.UTF8;
        /// <summary>
        /// 编码
        /// </summary>
        public Encoding Encoding
        {
            get { return _encoding; }
            set { _encoding = value; }
        }

        private WebProxy _proxy;
        /// <summary>
        /// 代理
        /// </summary>
        public WebProxy Proxy
        {
            get { return _proxy; }
            set { _proxy = value; }
        }

        private string _contentType = "application/x-www-form-urlencoded";
        /// <summary>
        /// 内容类型
        /// </summary>
        public string ContentType
        {
            get { return _contentType; }
            set { _contentType = value; }
        }

        private string _acceptEncoding = "gzip,deflate,sdch";
        /// <summary>
        /// 浏览器可接受的编码
        /// </summary>
        public string AcceptEncoding
        {
            get { return _acceptEncoding; }
            set { _acceptEncoding = value; }
        }

        private string _acceptLanguage = "zh-CN,zh;q=0.8,de;q=0.6,en;q=0.4,zh-TW;q=0.2";
        /// <summary>
        /// 浏览器可接受的语言
        /// </summary>
        public string AcceptLanguage
        {
            get { return _acceptLanguage; }
            set { _acceptLanguage = value; }
        }

        private string _xRequestedWith = "XMLHttpRequest";
        /// <summary>
        /// 异步请求方式
        /// </summary>
        public string XRequestedWith
        {
            get { return _xRequestedWith; }
            set { _xRequestedWith = value; }
        }

        private string _accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
        /// <summary>
        /// 浏览器支持的 MIME 类型
        /// </summary>
        public string Accept
        {
            get { return _accept; }
            set { _accept = value; }
        }

        private bool _keepAlive = true;
        /// <summary>
        /// 是否建立持久性连接
        /// </summary>
        public bool KeepAlive
        {
            get { return _keepAlive; }
            set { _keepAlive = value; }
        }

        private string _fileName = string.Empty;
        /// <summary>
        /// 文件名
        /// </summary>
        public string FileName
        {
            get { return _fileName; }
            set { _fileName = value; }
        }
    }

    public enum HttpMethod
    {
        GET,
        POST
    }
}